package forum.command;

import forum.entities.User;
import forum.services.UserService;

import java.math.BigInteger;

public class DeleteTopicCommand implements Command {

    private BigInteger topicId;
    private User user;
    private UserService userService = new UserService();

    @Override
    public void execute() {
        userService.deleteTopic(user,topicId);
    }

    @Override
    public void setParameters(String... args) {
        if (args.length != 1) {
            throw new IllegalArgumentException ("Incorrect number of arguments");
        }
        topicId = new BigInteger(args[0]);
    }

    @Override
    public void setContext(CommandContext context) {
        user = context.getUser();
    }

    @Override
    public void updateContext(CommandContext context) {

    }

    @Override
    public String help() {
        return "Type 'del_topic' | %topicId% to delete chosen topic";
    }
}
